const { Sequelize } = require("sequelize");

module.exports = (sequelize, DataTypes) => {
  const needHistory = sequelize.define(
    "needHistory",
    {
      // 变更信息----------
      updatedAt: {
        type: DataTypes.DATE, // 变更时间
      },
      changerName: {
        type: DataTypes.STRING(50),
        allowNull: false,
      },
      changerId: {
        type: DataTypes.INTEGER,
      },
      changedField: {
        type: DataTypes.JSON, // 变更字段
      },
      // 变更类型
      changeType: {
        type: DataTypes.STRING(10),
      },
      // need信息----------

      title: {
        type: DataTypes.STRING(255),
      },
      details: {
        type: DataTypes.TEXT,
      },
      creator: {
        type: DataTypes.STRING(50),
      },
      creatorId: {
        type: DataTypes.INTEGER,
        // allowNull: false,
      },
      createdAt: {
        type: DataTypes.DATE,
        // defaultValue: Sequelize.NOW, // 设置默认值为当前时间
      },
      // 处理人数组
      handlerArray: {
        type: DataTypes.JSON,
      },
      //优先级
      priority: {
        type: DataTypes.STRING(10),
      },
      startDate: {
        type: DataTypes.DATE,
      },
      endDate: {
        type: DataTypes.DATE,
      },
      completedDate: {
        type: DataTypes.DATE,
      },
      category: {
        type: DataTypes.STRING(50),
      },
      status: {
        type: DataTypes.STRING(50),
      },
      comment: {
        type: DataTypes.TEXT, // 评论
      },
      projectName: {
        type: DataTypes.STRING(50),
      },
      projectId: {
        type: DataTypes.INTEGER,
      },
    },
    {
      freezeTableName: true,
      timestamps: false,
    }
  );

  return needHistory;
};
